<template>
  <a-config-provider :locale="zhCN">
    <template #renderEmpty>
      <div style="text-align: center">
        <a-empty />
      </div>
    </template>
    <a-spin
      :spinning="loading"
      :delay="500"
      wrapper-class-name="spin-continer"
      size="large"
      tip="Loading..."
    >
      <router-view></router-view>
    </a-spin>
  </a-config-provider>
</template>

<script setup>
import zhCN from "ant-design-vue/es/locale/zh_CN";
import { postRsaKey } from "@/api/userCenter";
import { useStoreApp, useStoreCache, useStoreUser } from "@/store";
import dayjs from "dayjs";
import "dayjs/locale/zh-cn";
dayjs.locale("zh-cn");
// support Multi-language
// 仓库数据
const storeApp = useStoreApp();
const storeCache = useStoreCache();
const storeUser = useStoreUser();

const loading = computed(() => storeApp.loading);
const route = useRoute();

onMounted(() => {
  // postRsaKey().then(result => {
  //   let PUBLIC_KEY = result.data;
  //   storeUser.rsaKey = PUBLIC_KEY;
  // });
  if (storeUser.token) {
    storeUser.getUserInfo();
  storeUser.getFeedBackNum();
  }
});

watch(
  () => route,
  () => {
    storeCache.addCachedView(route);
  },
  {
    immediate: true,
    deep: true,
  }
);
storeApp.getAppConfig();
</script>

<style lang="less">
@import "./style/init.less";
@import "./style/main.less";
@import "./style/common.less";

#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #0b0f26;
  width: 100%;
  min-width: 1440px;
  height: 100%;
  // overflow: hidden;
  .spin-continer {
    width: 100%;
    height: 100%;
    .ant-spin-container {
      width: 100%;
      // width: calc(100% + 2px);
      height: 100%;
    }
    > div {
      > .ant-spin {
        position: fixed !important;
        max-height: none !important;
        z-index: 9999;
      }
    }
  }
}

#nav {
  padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>
